package com.itheima.edu.practice.demo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo {//map遍历
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("001","小芳");
        map.put("002","小美");
        map.put("003","小和");
        map.put("004","小尚");

//        //获取键，之后获取每个值
//        Set<String> keySet = map.keySet();
//        for (String s : keySet) {
//            System.out.println(s+"---"+map.get(s));
//        }
//
//        System.out.println("-----------");
//        //获得每对键对
//        Set<Map.Entry<String, String>> entrySet = map.entrySet();
//        for (Map.Entry<String, String> entry : entrySet) {
//            System.out.println(entry.getKey()+"---"+entry.getValue());
//        }

        Set<String> set = map.keySet();
        for(String s : set){
            System.out.println(s+"---"+map.get(s));
        }
        System.out.println("-----------");
        Set<Map.Entry<String,String>> mapEntry =map.entrySet();
        for(Map.Entry<String,String> entry : mapEntry){
            System.out.println(entry.getKey()+"---"+entry.getValue());
        }
    }
}
